The Python Bible Volume 5: Python For Finance (Stock Analysis, Trading, Share Prices) by Florian Dedov
Author:Florian Dedov [Dedov, Florian]
Language: eng
Format: azw3
Publisher: UNKNOWN
Published: 2019-08-12T16:00:00+00:00
6 – S&P 500 Index
When we talk about how the markets are doing, we are usually looking at indices. One of the most important indices is the so-called S&P 500 index which measures the stock performance of the 500 largest companies listed on the US stock exchanges.
Up until now, we always downloaded financial data for individual stocks from the internet. But when we are doing larger calculations many times, it would be preferable to not need to bother the Yahoo Finance API every time.
For this reason, we can download the stock data of the 500 companies which are represented in the S&P 500 right now and save them into files. We can then use these files instead of making requests to the API all the time.
Webscraping
The Yahoo Finance API doesn’t offer any possibilities to request all the companies of the S&P 500 index. Therefore, we will need to get the information about which companies are represented from somewhere else. And for this, we will need something called webscraping .
With webscraping we are reading the HTML files of a website, in order to extract some specific information we are looking for. In this case, we are going to use the Wikipedia page of the list of S&P 500 companies to get the information we need.
Link: https://en.wikipedia.org/wiki/List_of_S%26P_500_companies
On this page, we can find a table with all the 500 companies and different information about them. We can see the name of the company, the industry, the headquarters location and some more things. What we need however is the ticker symbol, which we can find in the first column (make sure you take a look at the page yourself, since the structure of the table might change from time to time).
To now understand how we can extract the information out of this website, we need to look at the HTML code. For this, we go into our browser, make a right click and view the source code of the page.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7891)
Hadoop in Practice by Alex Holmes(5682)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5535)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4551)
Functional Programming in JavaScript by Mantyla Dan(3740)
The Age of Surveillance Capitalism by Shoshana Zuboff(3463)
Big Data Analysis with Python by Ivan Marin(3234)
Blockchain Basics by Daniel Drescher(2923)
Test-Driven Development with Java by Alan Mellor(2827)
The Rosie Effect by Graeme Simsion(2742)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2675)
Data Augmentation with Python by Duc Haba(2670)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2589)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2513)
Principles of Data Fabric by Sonia Mezzetta(2487)
Dawn of the New Everything by Jaron Lanier(2457)
The Infinite Retina by Robert Scoble Irena Cronin(2417)
The Art Of Deception by Kevin Mitnick(2324)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(2260)